<?php

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAdminMenusTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (config('admin.verify_permissions') == false) {
            Schema::create('admin_menus', function (Blueprint $table) {
                $table->engine = 'InnoDB';
                $table->increments('id');
                $table->integer('user_id')->default(0)->comment('管理员ID');
                $table->integer('menu_id')->default(0)->comment('菜单ID');
                $table->dateTime('created_at')->comment('创建时间');
                $table->dateTime('updated_at')->comment('修改时间');
            });

            DB::statement("ALTER TABLE `admin_menus` comment '管理员关联菜单表'");
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        if (config('admin.verify_permissions') == false) {
            Schema::dropIfExists('admin_menus');
        }
    }
}
